package com.wisezone.workflow.core;

import java.util.List;
import java.util.Map;

import com.wisezone.workflow.bean.WfActivity;
import com.wisezone.workflow.bean.WfProcessInstance;
import com.wisezone.workflow.bean.form.WfActivityInstanceForm;
import com.wisezone.workflow.bean.search.WfActivityInstanceSearch;
import com.wisezone.workflow.bean.search.WfActivitySearch;
import com.wisezone.workflow.exception.WfCoreException;

/**
 * 流程实例对象
 * @author tss 2009-09-05
 *
 */
public interface ProcessInstance  extends BaseProperty  {

	
	/**
	 * 流程启动
	 * @return
	 * @throws WfCoreException
	 */
	public ProcessInstance start() throws WfCoreException ;
	
	/**
	 * 流程启动
	 * @return
	 * @throws WfCoreException
	 */
	public ProcessInstance start(Map<String, Object> variableMap) throws WfCoreException ;

	/**
	 * 流程结束
	 * @return
	 * @throws WfCoreException
	 */
	public ProcessInstance end() throws WfCoreException ;
	
	/**
	 * 流程暂停
	 * @return
	 * @throws WfCoreException
	 */
	public ProcessInstance pause() throws WfCoreException ;
	
	/**
	 * 流程恢复
	 * @return
	 * @throws WfCoreException
	 */
	public ProcessInstance  resume() throws WfCoreException;
	
	/**
	 * 设置流程启动者
	 * @param starter
	 * @return
	 * @throws WfCoreException
	 */
	public ProcessInstance setStarter(Long starter) throws WfCoreException ;
	
	/**
	 * 设置流程实例名称
	 * @param starter
	 * @return
	 * @throws WfCoreException
	 */
	public ProcessInstance setName(String name) throws WfCoreException;
	
	/**
	 * 设置备注
	 * @param memo
	 * @return
	 * @throws WfCoreException
	 */
	public ProcessInstance setMemo(String memo) throws WfCoreException ;
	
	
	
	
    /**
     * 开始活动
     * @return
     * @throws WfCoreException
     */
	public ActivityInstance startActivityInstance() throws WfCoreException ;
	
	
	/**
	 * 加载开始活动
	 * @return
	 * @throws WfCoreException
	 */
	public ActivityInstance loadStartActivityInstance() throws WfCoreException ;
	
	
	
	/**
	 * 加载结束活动
	 * @return
	 * @throws WfCoreException
	 */
	public ActivityInstance loadEndActivityInstance() throws WfCoreException ;
	
	/**
	 * 跟据ID 加载该流程下的活动
	 * @param id
	 * @return
	 * @throws WfCoreException
	 */
	public ActivityInstance loadActivityInstById(Long id) throws WfCoreException ;
	
	/**
	 * 获得活动实例表单列表
	 * @return
	 * @throws WfCoreException
	 */
	public List<WfActivityInstanceForm> getActivityInstFormList() throws WfCoreException;
	
	/**
	 *  创建活动实例
	 * @param searchEntity
	 * @param actorIds
	 * @param category
	 * @return
	 * @throws WfCoreException
	 */
	public ActivityInstance createActivityInstance(WfActivity wfActivity,Long [] actorIds,Long [] nextActorGroupIds)
	throws WfCoreException;
	
	/**
	 * 创建活动实例集合
	 * @param searchEntity
	 * @param actorIds
	 * @param category
	 * @return
	 * @throws WfCoreException
	 */
	public List<ActivityInstance> createActivityInstList(WfActivitySearch searchEntity,Long [] actorIds,Long [] nextActorGroupIds)
	throws WfCoreException ;


	/**
	 * 获得流程实例下的所有未开始的活动
	 * @return
	 * @throws WfCoreException
	 */
	public List<ActivityInstance> getNotStartActivityInstList() throws WfCoreException ;	
	

	
	/**
	 * 获得流程实例下的所有已结束的活动
	 * @return
	 * @throws WfCoreException
	 */
	public List<ActivityInstance> getEndedActivityInstList() throws WfCoreException ;	
	

	
	

	/**
	 * 获得流程实例下的所有活动
	 * @return
	 * @throws WfCoreException
	 */
	public List<ActivityInstance> getActivityInstList() throws WfCoreException ;	
	
	
	/**
	 * 获得流程实例下的所有活动(根据条件)
	 * @return
	 * @throws WfCoreException
	 */
	public List<ActivityInstance> getActivityInstList(WfActivityInstanceSearch search) throws WfCoreException ;	
	


	
	/**
	 * 删除该流程下的活动实例
	 * @param ai
	 * @throws WfCoreException
	 */
	public void delete(ActivityInstance ai) throws WfCoreException ;	
	

	
	/**
	 * 删除该流程下的活动实例集合
	 * @param activityList
	 * @throws WfCoreException
	 */
	public void deleteList(List<ActivityInstance> activityList) throws WfCoreException;	
	
	/**
	 * 逻辑删除流程实例集合
	 * @param userId
	 * @throws WfCoreException
	 */
	public void logicDelActivityInstList(Long userId) throws WfCoreException;
	
	
	/**
	 * 修改流程实例
	 * @param wfProcessInstance
	 * @return
	 * @throws WfCoreException
	 */
	public ProcessInstance update(WfProcessInstance wfProcessInstance) throws WfCoreException	;
	

	/**
	 * 流程实例是否结束
	 * @return
	 * @throws WfCoreException
	 */
	public boolean isEnd() throws WfCoreException;
	
	/**
	 * 获得流程实例变量
	 */
	public Object getVariable(String name) throws WfCoreException;
	
	/**
	 * 设置流程实例变量
	 * @param name
	 * @param value
	 * @throws WfCoreException
	 */
	public void setVariable(String name,String value) throws WfCoreException;
	

	public ProcessDefinition getProcessDefinition() ;	
	


	public void setProcessDefinition(ProcessDefinition processDefinition);	
	


	public WfProcessInstance getModel() ;	
	


	public void setModel(WfProcessInstance wfProcessInstance) ;	
	


}
